package br.edu.senac.repository.impl;

import org.apache.log4j.Logger;
import org.hibernate.Session;

import br.edu.senac.model.Ingrediente;
import br.edu.senac.repository.IngredienteRepository;
import br.edu.senac.util.HibernateUtil;

public class IngredienteRepositoryImpl implements IngredienteRepository {
	
	static Logger log = Logger.getLogger(IngredienteRepositoryImpl.class);

	@Override
	public void salvar(Ingrediente ingrediente) {
		
		Session session = HibernateUtil.getSession();
		try {
			log.info("|- Salvando: " + ingrediente + " - " + "IngredienteRepositoryImpl");
			session.beginTransaction();
			session.save(ingrediente);
			session.getTransaction().commit();
		} catch (Exception e) {
			session.getTransaction().rollback();
			e.printStackTrace();
		} finally {

		}

	}

}
